//
// Created by THE13 on 2024/2/6.
//

#ifndef CHICHIBOOM_UI_SIMLATOR_PAGE_H
#define CHICHIBOOM_UI_SIMLATOR_PAGE_H

#include <cstdlib>
#include <cstdint>
#include <cstdio>

#include "animation_sysfun.h"

/*============================ struct ============================*/
//1.page type
//2.item type
//3.page state
//4.sys  info

typedef enum page_type_{//page type
    LIST,
    ICON,
    DATA,
    TEXT,
}PageType;

typedef enum item_type_{//item type
    ITEM_TEXT,
    ITEM_SWITCH,
    ITEM_CHECKBOX,
    ITEM_PROGRESS_BAR,
    ITEM_CALL_PAGE,
    ITEM_CALL_FUNCTION,
}ItemType;

typedef enum page_state_{//page state
    onViewLoard,
    onViewDidLoard,
    onViewWillAppear,
    onViewDidAppear,
    onViewWillDisappear,
    onViewDidDisappear,
    onViewDidUnloard
}PageState;


typedef struct _menu
{
    struct _menu * next;//子级菜单
    struct _menu * last;//父极菜单指针
    struct _menu * same_last;//同级菜单下一项指针
    struct _menu * same_next;//同级菜单上一项指针
    PageState state;
    PageType pagetype;
    ItemType itemtype;
    const char * name;//当前功能名称
    int id;//当前功能号
    uint16_t *iconSrc;
    uint16_t param1;
    uint16_t param2;
    uint8_t pos_x;
    uint8_t pos_y;
    SecondOrderDynamics_t * ani;
    void (*callback)();
}menu_t;


typedef struct _sys_info{
    menu_t   *now;//当前链表位置
    int      ctrl;
    char     input;
}_sys_info_t;

/*============================ extern param ============================*/
extern _sys_info_t sys_info;
extern uint16_t page_cnt;//页面计数器，用来计算时间

/*============================ extern function ============================*/
void    SysInfo_init(menu_t *node);
menu_t* AddNode(menu_t *node,const char *name);
menu_t* AddPage(menu_t *node,PageType type,const char *name);
void    AddItem(struct _menu *page,ItemType itemType,const char *name,uint16_t* iconSrc,uint16_t param1,uint16_t param2,void (* callback)());

#endif //CHICHIBOOM_UI_SIMLATOR_PAGE_H
